package com.nbsaas.boot.order.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "订单", model = "订单")
@Entity
@Table(name = "bs_order")
@Comment("订单主表")
public class Order extends AbstractEntity {

    @Comment("订单编号")
    @FormField(title = "订单编号", sortNum = "1", grid = true, required = true)
    @Column(name = "order_no", nullable = false, unique = true, length = 64)
    private String orderNo;

    @Comment("用户ID")
    @FormField(title = "用户ID", sortNum = "2", grid = true, required = true)
    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Comment("店铺ID")
    @FormField(title = "店铺ID", sortNum = "3", grid = true, required = true)
    @Column(name = "shop_id", nullable = false)
    private Long shopId;

    @Comment("订单类型")
    @FormField(title = "订单类型", sortNum = "4", grid = true, type = InputType.select)
    @Column(name = "order_type", nullable = false)
    private Integer orderType = 1;

    @Comment("订单状态")
    @FormField(title = "订单状态", sortNum = "5", grid = true, type = InputType.select)
    @Column(name = "order_status", nullable = false)
    private Integer orderStatus = 1;

    @Comment("支付状态")
    @FormField(title = "支付状态", sortNum = "6", grid = true, type = InputType.select)
    @Column(name = "pay_status", nullable = false)
    private Integer payStatus = 0;

    @Comment("配送状态")
    @FormField(title = "配送状态", sortNum = "7", grid = true, type = InputType.select)
    @Column(name = "delivery_status", nullable = false)
    private Integer deliveryStatus = 0;

    @Comment("订单总金额")
    @FormField(title = "订单总金额", sortNum = "8", grid = true, type = InputType.el_input_number)
    @Column(name = "total_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal totalAmount = BigDecimal.ZERO;

    @Comment("实付金额")
    @FormField(title = "实付金额", sortNum = "9", grid = true, type = InputType.el_input_number)
    @Column(name = "pay_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal payAmount = BigDecimal.ZERO;

    @Comment("运费")
    @FormField(title = "运费", sortNum = "10", grid = true, type = InputType.el_input_number)
    @Column(name = "freight_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal freightAmount = BigDecimal.ZERO;

    @Comment("优惠金额")
    @FormField(title = "优惠金额", sortNum = "11", grid = true, type = InputType.el_input_number)
    @Column(name = "discount_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal discountAmount = BigDecimal.ZERO;

    @Comment("税费")
    @FormField(title = "税费", sortNum = "12", grid = true, type = InputType.el_input_number)
    @Column(name = "tax_amount", nullable = false, precision = 10, scale = 2)
    private BigDecimal taxAmount = BigDecimal.ZERO;

    @Comment("支付时间")
    @FormField(title = "支付时间", sortNum = "13", type = InputType.date, grid = true)
    @Column(name = "pay_time")
    private LocalDateTime payTime;

    @Comment("发货时间")
    @FormField(title = "发货时间", sortNum = "14", type = InputType.date, grid = true)
    @Column(name = "delivery_time")
    private LocalDateTime deliveryTime;

    @Comment("收货时间")
    @FormField(title = "收货时间", sortNum = "15", type = InputType.date, grid = true)
    @Column(name = "receive_time")
    private LocalDateTime receiveTime;

    @Comment("取消时间")
    @FormField(title = "取消时间", sortNum = "16", type = InputType.date, grid = true)
    @Column(name = "cancel_time")
    private LocalDateTime cancelTime;

    @Comment("退款时间")
    @FormField(title = "退款时间", sortNum = "17", type = InputType.date, grid = true)
    @Column(name = "refund_time")
    private LocalDateTime refundTime;

    @Comment("买家留言")
    @FormField(title = "买家留言", sortNum = "18", type = InputType.textarea)
    @Column(name = "buyer_message", length = 500)
    private String buyerMessage;

    @Comment("卖家留言")
    @FormField(title = "卖家留言", sortNum = "19", type = InputType.textarea)
    @Column(name = "seller_message", length = 500)
    private String sellerMessage;

    @Comment("发票类型")
    @FormField(title = "发票类型", sortNum = "20", grid = true, type = InputType.select)
    @Column(name = "invoice_type")
    private Integer invoiceType = 0;

    @Comment("发票抬头")
    @FormField(title = "发票抬头", sortNum = "21", grid = true)
    @Column(name = "invoice_title", length = 100)
    private String invoiceTitle;

    @Comment("发票内容")
    @FormField(title = "发票内容", sortNum = "22", grid = true)
    @Column(name = "invoice_content", length = 200)
    private String invoiceContent;

    @Comment("订单来源")
    @FormField(title = "订单来源", sortNum = "23", grid = true, type = InputType.select)
    @Column(name = "source_type")
    private Integer sourceType = 1;

    @Comment("来源ID")
    @FormField(title = "来源ID", sortNum = "24", grid = true)
    @Column(name = "source_id", length = 64)
    private String sourceId;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "25", type = InputType.textarea)
    @Column(name = "remark", length = 500)
    private String remark;
} 